<%@page import="fr.uparis10.m2miageclassic.entity.UFRs"%>
<%@page import="fr.uparis10.m2miageclassic.entity.TypeDiplome"%>
<%@page import="fr.uparis10.m2miageclassic.entity.Domaine"%>
<%@page import="fr.uparis10.m2miageclassic.entity.Diplome"%>
<%@ page import="javax.naming.*"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%!    private fr.uparis10.m2miageclassic.interfaces.MaquetteItf maquette = null;

    public void jspInit() {
        try {
            InitialContext ctx = new InitialContext();
            maquette = (fr.uparis10.m2miageclassic.interfaces.MaquetteItf) ctx.lookup("Maquette");
        } catch (Exception ex) {
            System.out.println("Couldn't create converter bean." + ex.getMessage());
        }
    }

    public void jspDestroy() {
        maquette = null;
    }
    Diplome diplome;
%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
    <head>
        <meta http-equiv="Content-Type" content="text/html" />
        <title>Maquettes Paris Ouest - Accueil</title>
        <link href="medias/jotform.css" rel="stylesheet" type="text/css" />
        <link href="medias/style.css" rel="stylesheet" type="text/css" />

    </head>

    <body>
        <% diplome = maquette.getDiplome(Long.parseLong(request.getParameter("dipid")));%>
        <div id="container">
            <div id="header">
                <div id="header_logo">
                    <div id="header_right" style="text-align: right">
                        <div style ="margin-bottom: auto">Utilisateur :<//sec:authentication property="principal.username"/></div>
                        <a href="j_spring_security_logout">Déconnexion</a>
                    </div>
                </div>
            </div>


            <div id="middle">

                <div id="middle_menu">

                    <ul>
                        <li><a href="accueil.htm">Accueil</a></li>
                        <li><a href="create.htm">Créer maquette</a></li>
                        <li><a href="">Rehabiliter maquette</a></li>
                        <li><a href="">Habilitations</a></li>

                        <li><a href="http://www.univ-paris10.fr">Portail Paris Ouest</a></li>
                    </ul>

                </div>
                <div id="middle_main">					
                    <script src="medias/jotform.js" type="text/javascript"></script>
                    <script type="text/javascript">
                        JotForm.init();
                    </script>
                    <form class="jotform-form" action="editSuccess.htm" method="get" accept-charset="utf-8">
                        <div class="form-all">
                            <ul class="form-section">
                                <li class="form-line" id="id_3">
                                    <label class="form-label-left" id="label_3" for="input_3"> Type de dipl&ocirc;me </label>
                                    <div id="cid_3" class="form-input">
                                        <select class="form-dropdown" style="width:150px" id="input_3" name="q3_typeDe">
                                            <%if (diplome.getTypeDiplomes() != null) {%>
                                            <option value="<%=diplome.getTypeDiplomes().getId()%>"><%=diplome.getTypeDiplomes().getNiveau()%></option>
                                            <%}%>
                                            
                                            <%for (TypeDiplome typ : maquette.getLesTypeDiplome()) {
                                                if (diplome.getTypeDiplomes() != null) {
                                                    if (!diplome.getTypeDiplomes().getId().equals(typ.getId())) {
                                            %>
                                            <option value="<%=typ.getId()%>"> <%= typ.getNiveau()%> </option>
                                            <%}}else{%>
                                            <option value="<%=typ.getId()%>"> <%= typ.getNiveau()%> </option>
                                                <%}}%>
                                        </select>
                                    </div>
                                </li>
                                <li class="form-line" id="id_4">
                                    <label class="form-label-left" id="label_4" for="input_4"> UFR </label>
                                    <div id="cid_4" class="form-input">
                                        <select class="form-dropdown" style="width:150px" id="input_4" name="q4_ufr" onchange="">
                                            <%if (!diplome.getUfrs().isEmpty()) {%>
                                            <option value ="<%=diplome.getUfrs().get(0).getId()%>"><%=diplome.getUfrs().get(0).getNom()%></option>
                                            <%}%>
                                            <%for (UFRs ufr : maquette.getLesUFRs()) {
                                                    if (diplome.getUfrs().isEmpty()) {
                                            %>
                                            <option value="<%=ufr.getId()%>"> <%= ufr.getNom()%> </option>
                                            <%} else {
                                                if (!ufr.getId().equals(diplome.getUfrs().get(0).getId())) {

                                            %>
                                            <option value="<%=ufr.getId()%>"> <%= ufr.getNom()%> </option>
                                            <%}
                                                    }
                                                }%>
                                        </select>
                                    </div>
                                </li>
                                <li class="form-line" id="id_5">
                                    <label class="form-label-left" id="label_5" for="input_5"> Domaine </label>
                                    <div id="cid_5" class="form-input">
                                        <select class="form-dropdown" style="width:150px" id="input_5" name="q5_domaine">
                                            <%if (!diplome.getUfrs().isEmpty() ) {
                                              if(!diplome.getUfrs().get(0).getDomaines().isEmpty()){  
                                            %>
                                            <option value="<%=diplome.getUfrs().get(0).getDomaines().get(0).getId()%>"><%=diplome.getUfrs().get(0).getDomaines().get(0).getNom()%></option>
                                            <%}}%>
                                            <%for (Domaine domaine : maquette.getLesDomaine()) {
                                                    if (diplome.getUfrs().isEmpty()) {%>
                                            <option  value="<%=domaine.getId()%>"> <%= domaine.getNom()%> </option>
                                            <%} else { 
                                                        if(diplome.getUfrs().get(0).getDomaines().isEmpty()){                                           
                                            if (!diplome.getUfrs().get(0).getDomaines().get(0).getId().equals(domaine.getId())){%>
                                            <option  value="<%=domaine.getId()%>"> <%= domaine.getNom()%> </option>
                                            <%}
                                                                                              } }
                                                }%>
                                        </select>
                                    </div>
                                </li>
                                <li class="form-line" id="id_6">
                                    <label class="form-label-left" id="label_6" for="input_6"> Mention </label>
                                    <div id="cid_6" class="form-input">
                                        <input type="text" class="form-textbox" id="input_6" name="q6_mention" size="20" value ="<%=diplome.getMention().getNom()%> "/>
                                    </div>
                                </li>
                                <li class="form-line" id="id_7">
                                    <label class="form-label-left" id="label_7" for="input_7"> Sp&eacute;cialit&eacute; </label>
                                    <div id="cid_7" class="form-input">
                                        <%if(!diplome.getMention().getSpecialites().isEmpty()){%>
                                        <input type="text" class="form-textbox" id="input_7" name="q7_specialite" size="20" value ="<%=diplome.getMention().getSpecialites().get(0).getNom()%>" />
                                        <%}else{%>
                                        <input type="text" class="form-textbox" id="input_7" name="q7_specialite" size="20" value ="" />
                                        <%}%>
                                    </div>
                                </li>
                                <li class="form-line" id="id_8">
                                    <label class="form-label-left" id="label_8" for="input_8"> Dipl&Ocirc;me </label>
                                    <div id="cid_8" class="form-input">
                                        <input type="text" class="form-textbox" id="input_8" name="q8_diplome" size="20" value ="<%=diplome.getNom()%>" />
                                    </div>
                                </li>
                                <li class="form-line" id="id_9">
                                    <div id="cid_9" class="form-input-wide">
                                        <div style="margin-left:0px" class="form-buttons-wrapper">
                                            <button id="input_9" type="submit" class="form-submit-button">
                                                Soumettre le formulaire
                                            </button>
                                        </div>
                                    </div>
                                </li>
                                <li style="display:none">
                                    Should be Empty:
                                    <input type="text" name="website" value="" />
                                </li>
                            </ul>
                        </div>
                        <input type="hidden" id="simple_spc" name="simple_spc" value="20303637549" />
                        <input type="hidden" id="iddiplome" name="iddip" value="<%=diplome.getId()%>" />
                    </form>
                </div>
            </div>

        </div>

    </body>
</html>
